package com.ssy.lingxi.platform.manage.controller;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.platform.manage.api.model.dto.sensitive.*;
import com.ssy.lingxi.platform.manage.api.model.vo.sensitive.SensitiveWordFilterVO;
import com.ssy.lingxi.platform.manage.api.model.vo.sensitive.SensitiveWordListFilterVO;
import com.ssy.lingxi.platform.manage.entity.base.SensitiveWord;
import com.ssy.lingxi.platform.manage.service.ISensitiveWordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @menu 平台后台-系统管理-敏感词管理
 * @author yzc
 * @version 2.0.0
 * @date 2020/10/27
 */
@Api(tags = "平台后台-系统管理-敏感词管理")
@RestController
@RequestMapping("/manage/sensitiveWord")
public class SensitiveWordController{

    @Resource
    private ISensitiveWordService sensitiveWordService;

    /**
     * 平台后台-系统管理-敏感词管理-分页列表
     * @param request 接口参数
     * @return 返回结果 返回结果
     */
    @GetMapping("/page")
    public Wrapper<PageData<SensitiveWord>> pageSensitiveWord(SensitiveWordPageDTO request) {
        return sensitiveWordService.pageSensitiveWord(request);
    }

    /**
     * 平台后台-系统管理-敏感词管理-添加
     * @param request 接口参数
     * @return 返回结果
     */
    @ApiOperation(value = "平台后台-系统管理-敏感词管理-添加")
    @PostMapping("/add")
    public Wrapper<Void> addSensitiveWord(@RequestBody @Validated(SensitiveWordDTO.Add.class) SensitiveWordDTO request) {
        return sensitiveWordService.addSensitiveWord(request);
    }

    /**
     * 平台后台-系统管理-敏感词管理-修改
     * @param request 接口参数
     * @return 返回结果
     */
    @PostMapping("/update")
    public Wrapper<Void> updateSensitiveWord(@RequestBody @Validated(SensitiveWordDTO.Update.class) SensitiveWordDTO request) {
        return sensitiveWordService.updateSensitiveWord(request);
    }

    /**
     * 平台后台-系统管理-敏感词管理-删除
     * @param request 接口参数
     * @return 返回结果
     */
    @PostMapping("/delete")
    public Wrapper<Void> deleteSensitiveWord(@RequestBody @Validated SensitiveWordDeleteByIdDTO request) {
        return sensitiveWordService.deleteSensitiveWord(request);
    }

    /**
     * 平台后台-系统管理-敏感词管理-批次删除
     * @param request 接口参数
     * @return 返回结果
     */
    @PostMapping("/deleteByBatchNo")
    public Wrapper<Void> deleteSensitiveWordByBatchNo(@RequestBody @Validated SensitiveWordDeleteByBatchNoDTO request) {
        return sensitiveWordService.deleteSensitiveWordByBatchNo(request);
    }

    /**
     * 内部接口-敏感词过滤
     * @param request 接口参数
     * @return 返回结果
     */
    @PostMapping("/filter")
    public Wrapper<SensitiveWordFilterVO> filterSensitiveWord(@RequestBody @Validated SensitiveWordFilterDTO request) {
        return sensitiveWordService.filterSensitiveWord(request);
    }

    /**
     * 内部接口-敏感词过滤(多个)
     * @param request 接口参数
     * @return 返回结果
     */
    @PostMapping("/filterList")
    public Wrapper<SensitiveWordListFilterVO> filterSensitiveWordList(@RequestBody @Validated SensitiveWordListFilterDTO request) {
        return sensitiveWordService.filterSensitiveWordList(request);
    }
}
